package com.bw.mallshop.adapter;

import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

public class HomeTxtAdapter extends BannerAdapter<String, HomeTxtAdapter.HomeTxtVH> {

    public HomeTxtAdapter(List<String> datas) {
        super(datas);
    }

    @Override
    public HomeTxtVH onCreateHolder(ViewGroup parent, int viewType) {
        TextView textView = new TextView(parent.getContext());
        textView.setGravity(Gravity.CENTER_VERTICAL);
        ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        textView.setLayoutParams(lp);
        return new HomeTxtVH(textView);
    }

    @Override
    public void onBindView(HomeTxtVH holder, String data, int position, int size) {
        holder.textView.setText(data);
    }

    public static class HomeTxtVH extends RecyclerView.ViewHolder{

        TextView textView;
        public HomeTxtVH(@NonNull View itemView) {
            super(itemView);
            textView = (TextView) itemView;
        }
    }

}
